package com.wm.blog_web.feign.factory;

import com.wm.blog_web.feign.PictureFeignClient;
import com.wm.blog_web.feign.fallback.PictureClientFallbackImpl;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 图片断路器工厂
 *
 * @author wm_yu        hystrix服务降级
 * @date 2019/3/23 23:38
 */
@Component
@Slf4j
public class PictureClientFallbackFactory implements FallbackFactory<PictureFeignClient> {

    @Override
    public PictureFeignClient create(Throwable throwable) {
        PictureClientFallbackImpl userServiceClientFallback = new PictureClientFallbackImpl();
        //userServiceClientFallback.setThrowable(throwable);   todo
        userServiceClientFallback.setThrowable(throwable);
        log.info("调用图片服务feign异常:{}",throwable);
        return userServiceClientFallback;
    }
}
